﻿using System.Collections.ObjectModel;
using System.Device.Location;
using Caliburn.Micro;
using Ninject;
using Spotted.Data.Entities;
using Spotted.Data.Repositories;

namespace Spotted.ViewModels
{
    public class PlacesMapViewModel : ViewModelBase
    {
        private readonly IEventAggregator _eventAggregator;
        private readonly INavigationService _navigationService;

        [Inject]
        public IPlacesRepository PlacesRepository { get; set; }

        public PlacesMapViewModel(IEventAggregator eventAggregator, INavigationService navigationService) : base(navigationService)
        {
            // assign to private members
            _eventAggregator = eventAggregator;
            _navigationService = navigationService;

            // assign properties
            ZoomLevel = 19;
            CenterLocation = new GeoCoordinate(42.0058, -87.6612);
        }

        // properties
        public int ZoomLevel { get; set; }
        public GeoCoordinate CenterLocation { get; set; }
        public ObservableCollection<Place> Places
        {
            get { return new ObservableCollection<Place>(PlacesRepository.Places); }
        }

        // behaviors
        public void AddLocation()
        {
            _navigationService.UriFor<AddLocationViewModel>().Navigate();
        }
    }
}
